<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
	ServletContext context = pageContext.getServletContext();
	String roleid = (String) context.getAttribute("roleid");
%>
<div style="height:100%; width:100%;">
    <a href="javascript:saveactions()" class="easyui-linkbutton" style=" width:80px;float: right" id="btnSave">保 存</a>
    <ul id="tt"></ul> 
</div>

<script type="text/javascript">
    $(function() {
        $('#tt').tree({
            url: '<%=basePath%>/system/action/getActionTree?id=<%=roleid %>',
            checkbox: true,
            lines:true,
            loadFilter: function (rows) {
                return convert(rows);
            }
        });
    });
    function saveactions() {
        var ids="";
        var nodes = $('#tt').tree('getChecked', ['checked', 'indeterminate']);
        debugger 
        for (var i=0;i<nodes.length; i++) {
            ids += nodes[i].id + ",";
        }
        var post = {
            action: ids
        };
        $.post('<%=basePath%>/system/role/saveRoleAuthrization?id=<%=roleid %>',post, function (data) {
            $('#storedetail').dialog('close');
        });
    }
</script>